﻿Imports System.Data
Imports System.Data.SqlClient
Imports CondorTravel.BE
Imports CondorTravelUTIL.DL

Public Class EstadoDocDALC

    Public Function ListarEstados(ByVal objEstaDoc As EstadoDocBE) As List(Of EstadoDocBE)
        Dim sqlListar As String
        Dim objListaEstadoDoc As New List(Of EstadoDocBE)
        Dim objEstadoDocBE As EstadoDocBE = Nothing
        Dim arrSqlParameter(0) As SqlParameter
        Dim ds As DataSet
        Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        Dim blnExito As Boolean
        Dim strMensaje As String = String.Empty
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_EstadosList"

            arrSqlParameter(0) = New SqlParameter("@TIPO", System.Data.SqlDbType.VarChar)
            arrSqlParameter(0).Value = objEstaDoc.Tipo

            ds = objDatos.DevuelveDataSet(sqlListar, blnExito, strMensaje, arrSqlParameter)
            dt = ds.Tables(0)


            objListaEstadoDoc = New List(Of EstadoDocBE)()

            If dt.Rows.Count > 0 Then

                While intI < dt.Rows.Count
                    objEstadoDocBE = New EstadoDocBE()
                    objEstadoDocBE.Codigo = dt.Rows(intI).ItemArray(0).ToString
                    objEstadoDocBE.Descripcion = dt.Rows(intI).ItemArray(1).ToString
                    intI = intI + 1

                    objListaEstadoDoc.Add(objEstadoDocBE)
                End While
            End If

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objListaEstadoDoc
    End Function
End Class
